#include "lvgl.h"

#ifndef HUMITURE_FONT
#define HUMITURE_FONT 1
#endif

#if HUMITURE_FONT

/*-----------------
 *    BITMAPS
 *----------------*/

/*Store the image of the glyphs*/
static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = {

    /* U+25 "%" */
    0xa, 0xff, 0xd1, 0x0, 0x0, 0x3f, 0x50, 0x7, 
    0xf6, 0x3e, 0xa0, 0x0, 0xc, 0xc0, 0x0, 0xcc, 
    0x0, 0x7e, 0x10, 0x5, 0xf3, 0x0, 0xc, 0xa0, 
    0x5, 0xf3, 0x0, 0xca, 0x0, 0x0, 0xe7, 0x0, 
    0x5f, 0x30, 0x7f, 0x30, 0x0, 0xc, 0xa0, 0x5, 
    0xf3, 0x1e, 0x70, 0x1, 0x0, 0xcc, 0x0, 0x7e, 
    0x17, 0xe2, 0x9f, 0xfd, 0x27, 0xf6, 0x3e, 0xa3, 
    0xf7, 0x7f, 0x63, 0xec, 0xa, 0xff, 0xd1, 0xae, 
    0x1a, 0xc0, 0x7, 0xe0, 0x0, 0x10, 0x3f, 0x50, 
    0xca, 0x0, 0x5f, 0x0, 0x0, 0xc, 0xc0, 0xc, 
    0xa0, 0x3, 0xe0, 0x0, 0x5, 0xf5, 0x0, 0xca, 
    0x0, 0x5f, 0x0, 0x1, 0xea, 0x0, 0xa, 0xc0, 
    0x7, 0xe0, 0x0, 0x7f, 0x30, 0x0, 0x5f, 0x63, 
    0xea, 0x0, 0x1e, 0xa0, 0x0, 0x0, 0x9f, 0xfd, 
    0x2, 

    /* U+2d "-" */
    0xff, 0xff, 0x18, 

    /* U+2f "/" */
    0x0, 0x0, 0x5, 0xf7, 0x0, 0x0, 0xa, 0xe1, 
    0x0, 0x0, 0x3f, 0xa0, 0x0, 0x0, 0x7f, 0x50, 
    0x0, 0x0, 0xce, 0x10, 0x0, 0x3, 0xf7, 0x0, 
    0x0, 0xa, 0xf3, 0x0, 0x0, 0x1e, 0xc0, 0x0, 
    0x0, 0x5f, 0x70, 0x0, 0x0, 0xaf, 0x30, 0x0, 
    0x1, 0xea, 0x0, 0x0, 0x7, 0xf5, 0x0, 0x0, 
    0xc, 0xe1, 0x0, 0x0, 0x3f, 0xa0, 0x0, 0x0, 
    0x7f, 0x30, 0x0, 0x0, 

    /* U+30 "0" */
    0x0, 0xaf, 0xff, 0xf6, 0x0, 0xa, 0xfd, 0x67, 
    0xff, 0x50, 0x5f, 0xc0, 0x0, 0x3f, 0xc0, 0xaf, 
    0x50, 0x0, 0xa, 0xf3, 0xce, 0x10, 0x0, 0x7, 
    0xf5, 0xee, 0x10, 0x0, 0x5, 0xf7, 0xec, 0x0, 
    0x0, 0x5, 0xf7, 0xec, 0x0, 0x0, 0x5, 0xf7, 
    0xec, 0x0, 0x0, 0x5, 0xf7, 0xee, 0x10, 0x0, 
    0x5, 0xf7, 0xce, 0x10, 0x0, 0x7, 0xf5, 0x7f, 
    0x50, 0x0, 0xa, 0xf3, 0x3f, 0xc0, 0x0, 0x3f, 
    0xc0, 0xa, 0xfd, 0x67, 0xff, 0x30, 0x0, 0x9f, 
    0xff, 0xd3, 0x0, 

    /* U+31 "1" */
    0x0, 0xc, 0xf0, 0x3f, 0xff, 0x7f, 0xd9, 0xfc, 
    0xc0, 0x7f, 0x0, 0x7, 0xf0, 0x0, 0x7f, 0x0, 
    0x7, 0xf0, 0x0, 0x7f, 0x0, 0x7, 0xf0, 0x0, 
    0x7f, 0x0, 0x7, 0xf0, 0x0, 0x7f, 0x0, 0x7, 
    0xf0, 0x0, 0x7f, 0x0, 0x7, 0x1e, 

    /* U+32 "2" */
    0x6, 0xef, 0xff, 0xd3, 0x9, 0xfe, 0x75, 0xaf, 
    0xf3, 0x17, 0x0, 0x0, 0x7f, 0xa0, 0x0, 0x0, 
    0x3, 0xfc, 0x0, 0x0, 0x0, 0x3f, 0xa0, 0x0, 
    0x0, 0x7, 0xf7, 0x0, 0x0, 0x0, 0xce, 0x10, 
    0x0, 0x0, 0xaf, 0x50, 0x0, 0x0, 0x7f, 0xa0, 
    0x0, 0x0, 0x6f, 0xa0, 0x0, 0x0, 0x5f, 0xc0, 
    0x0, 0x0, 0x5f, 0xc0, 0x0, 0x0, 0x3f, 0xd1, 
    0x0, 0x0, 0xe, 0xff, 0xdd, 0xdd, 0xdd, 0xef, 
    0xff, 0xff, 0xff, 0x1e, 

    /* U+33 "3" */
    0x2a, 0xff, 0xff, 0xd5, 0xd, 0xfc, 0x65, 0xaf, 
    0xf5, 0x22, 0x0, 0x0, 0x5f, 0xa0, 0x0, 0x0, 
    0x1, 0xec, 0x0, 0x0, 0x0, 0x3f, 0xa0, 0x0, 
    0x0, 0xa, 0xf5, 0x0, 0x7a, 0xbf, 0xf6, 0x0, 
    0xc, 0xff, 0xfc, 0x50, 0x0, 0x0, 0x3, 0xcf, 
    0x90, 0x0, 0x0, 0x0, 0xcf, 0x0, 0x0, 0x0, 
    0xa, 0xf0, 0x0, 0x0, 0x0, 0xaf, 0x0, 0x0, 
    0x0, 0x3f, 0xef, 0xc7, 0x56, 0xaf, 0xf5, 0xbf, 
    0xff, 0xff, 0xd5, 0x0, 

    /* U+34 "4" */
    0x0, 0x0, 0x0, 0x5f, 0xe1, 0x0, 0x0, 0x0, 
    0x1e, 0xfe, 0x10, 0x0, 0x0, 0xa, 0xec, 0xe1, 
    0x0, 0x0, 0x5, 0xf8, 0xce, 0x10, 0x0, 0x1, 
    0xea, 0xc, 0xe1, 0x0, 0x0, 0xae, 0x10, 0xce, 
    0x10, 0x0, 0x5f, 0x50, 0xc, 0xe1, 0x0, 0x1e, 
    0xa0, 0x0, 0xce, 0x10, 0xa, 0xe1, 0x0, 0xc, 
    0xe1, 0x5, 0xf5, 0x0, 0x0, 0xce, 0x10, 0xcf, 
    0xff, 0xff, 0xff, 0xff, 0xf7, 0xaa, 0xaa, 0xaa, 
    0xff, 0xb9, 0x0, 0x0, 0x0, 0xc, 0xe1, 0x0, 
    0x0, 0x0, 0x0, 0xce, 0x10, 0x0, 0x0, 0x0, 
    0xc, 0xe1, 0x0, 

    /* U+35 "5" */
    0xc, 0xff, 0xff, 0xff, 0x50, 0xcf, 0xdd, 0xdd, 
    0xd5, 0x1e, 0xc0, 0x0, 0x0, 0x1, 0xea, 0x0, 
    0x0, 0x0, 0x3f, 0xa0, 0x0, 0x0, 0x3, 0xf7, 
    0x12, 0x0, 0x0, 0x5f, 0xff, 0xff, 0xf7, 0x0, 
    0x77, 0x55, 0xaf, 0xf7, 0x0, 0x0, 0x0, 0x2e, 
    0xf0, 0x0, 0x0, 0x0, 0xaf, 0x0, 0x0, 0x0, 
    0x7, 0xf0, 0x0, 0x0, 0x0, 0xaf, 0x10, 0x0, 
    0x0, 0x3f, 0xea, 0xe8, 0x55, 0xaf, 0xf5, 0x6f, 
    0xff, 0xff, 0xd3, 0x0, 

    /* U+36 "6" */
    0x0, 0x7, 0xff, 0xff, 0x70, 0x0, 0xcf, 0xd7, 
    0x55, 0x30, 0x7, 0xf9, 0x0, 0x0, 0x0, 0x1e, 
    0xc0, 0x0, 0x0, 0x0, 0x5f, 0x70, 0x0, 0x0, 
    0x0, 0xaf, 0x30, 0x35, 0x10, 0x0, 0xae, 0x5d, 
    0xff, 0xfd, 0x20, 0xcf, 0xe7, 0x0, 0x5f, 0xe1, 
    0xcf, 0x70, 0x0, 0x7, 0xf5, 0xce, 0x10, 0x0, 
    0x5, 0xf7, 0xae, 0x10, 0x0, 0x3, 0xf7, 0x7f, 
    0x50, 0x0, 0x5, 0xf7, 0x3f, 0xc0, 0x0, 0xa, 
    0xf3, 0x7, 0xfe, 0x76, 0xdf, 0xa0, 0x0, 0x6f, 
    0xff, 0xf7, 0x0, 

    /* U+37 "7" */
    0xff, 0xff, 0xff, 0xff, 0xf7, 0xcd, 0xdd, 0xdd, 
    0xdf, 0xf7, 0x0, 0x0, 0x0, 0xa, 0xf3, 0x0, 
    0x0, 0x0, 0x3f, 0xa0, 0x0, 0x0, 0x0, 0x7f, 
    0x50, 0x0, 0x0, 0x1, 0xec, 0x0, 0x0, 0x0, 
    0x5, 0xf7, 0x0, 0x0, 0x0, 0xc, 0xe1, 0x0, 
    0x0, 0x0, 0x5f, 0xa0, 0x0, 0x0, 0x0, 0xaf, 
    0x30, 0x0, 0x0, 0x3, 0xfc, 0x0, 0x0, 0x0, 
    0xa, 0xf5, 0x0, 0x0, 0x0, 0x1e, 0xc0, 0x0, 
    0x0, 0x0, 0x7f, 0x70, 0x0, 0x0, 0x0, 0xce, 
    0x10, 0x0, 0x0, 

    /* U+38 "8" */
    0x2, 0xdf, 0xff, 0xf7, 0x0, 0x1e, 0xf8, 0x36, 
    0xdf, 0x70, 0x5f, 0xa0, 0x0, 0x1e, 0xe1, 0x7f, 
    0x70, 0x0, 0xc, 0xe1, 0x5f, 0xa0, 0x0, 0x1e, 
    0xc0, 0xc, 0xf7, 0x0, 0xcf, 0x50, 0x0, 0xcf, 
    0xff, 0xf5, 0x0, 0x0, 0x9f, 0xff, 0xd2, 0x0, 
    0x1d, 0xf7, 0x6, 0xff, 0x50, 0xaf, 0x70, 0x0, 
    0x1d, 0xf3, 0xce, 0x10, 0x0, 0x5, 0xf7, 0xee, 
    0x10, 0x0, 0x5, 0xf7, 0xaf, 0x30, 0x0, 0xa, 
    0xf5, 0x5f, 0xf7, 0x55, 0xaf, 0xa0, 0x3, 0xdf, 
    0xff, 0xf7, 0x0, 

    /* U+39 "9" */
    0x0, 0xaf, 0xff, 0xd2, 0x0, 0x1e, 0xfa, 0x57, 
    0xff, 0x30, 0x7f, 0x50, 0x0, 0x3f, 0xc0, 0xce, 
    0x10, 0x0, 0x7, 0xf3, 0xec, 0x0, 0x0, 0x5, 
    0xf7, 0xcc, 0x0, 0x0, 0x5, 0xf7, 0xaf, 0x30, 
    0x0, 0xa, 0xf7, 0x5f, 0xd2, 0x1, 0xaf, 0xf7, 
    0x7, 0xff, 0xff, 0xc8, 0xf7, 0x0, 0x4, 0x52, 
    0x7, 0xf5, 0x0, 0x0, 0x0, 0xc, 0xf3, 0x0, 
    0x0, 0x0, 0x3f, 0xc0, 0x0, 0x0, 0x1, 0xdf, 
    0x50, 0x5, 0x55, 0x8f, 0xf7, 0x0, 0xc, 0xff, 
    0xfd, 0x50, 0x0, 

    /* U+2103 "℃" */
    0x6, 0xff, 0xf7, 0x0, 0x0, 0x7, 0xff, 0xff, 
    0xfe, 0x55, 0xf6, 0x5, 0xf5, 0x0, 0x1d, 0xff, 
    0xb6, 0x8d, 0xf3, 0xaa, 0x0, 0x7, 0xa0, 0xc, 
    0xfc, 0x0, 0x0, 0x0, 0xa, 0xa0, 0x0, 0x7a, 
    0x5, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x5f, 0x60, 
    0x3f, 0x70, 0xaf, 0x50, 0x0, 0x0, 0x0, 0x0, 
    0x7f, 0xff, 0x90, 0x1e, 0xe1, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x2, 0x0, 0x3, 0xfc, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xc0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 
    0xfc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x1e, 0xe1, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0xcf, 0x50, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x7, 0xfa, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1e, 0xf8, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x3f, 0xff, 0xa6, 0x9b, 0xd1, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x19, 0xff, 0xff, 0xfc, 0x0, 
};

/*---------------------
 *  GLYPH DESCRIPTION
 *--------------------*/

static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
/* id = 0 reserved */  {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0},
/* U+25 "%" */  {.bitmap_index = 0, .adv_w = 264, .box_w = 15, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+2d "-" */  {.bitmap_index = 113, .adv_w = 104, .box_w = 5, .box_h = 1, .ofs_x = 1, .ofs_y = 5},
/* U+2f "/" */  {.bitmap_index = 116, .adv_w = 120, .box_w = 8, .box_h = 15, .ofs_x = 0, .ofs_y = 0},
/* U+30 "0" */  {.bitmap_index = 176, .adv_w = 184, .box_w = 10, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+31 "1" */  {.bitmap_index = 251, .adv_w = 184, .box_w = 5, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
/* U+32 "2" */  {.bitmap_index = 289, .adv_w = 184, .box_w = 9, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+33 "3" */  {.bitmap_index = 357, .adv_w = 184, .box_w = 9, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+34 "4" */  {.bitmap_index = 425, .adv_w = 184, .box_w = 11, .box_h = 15, .ofs_x = 0, .ofs_y = 0},
/* U+35 "5" */  {.bitmap_index = 508, .adv_w = 184, .box_w = 9, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+36 "6" */  {.bitmap_index = 576, .adv_w = 184, .box_w = 10, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+37 "7" */  {.bitmap_index = 651, .adv_w = 184, .box_w = 10, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+38 "8" */  {.bitmap_index = 726, .adv_w = 184, .box_w = 10, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+39 "9" */  {.bitmap_index = 801, .adv_w = 184, .box_w = 10, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
/* U+2103 "℃" */  {.bitmap_index = 876, .adv_w = 328, .box_w = 19, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
};

/*---------------------
 *  CHARACTER MAPPING
 *--------------------*/

static const uint16_t unicode_list_1[] = {

    0x25, 0x2d, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 
    0x35, 0x36, 0x37, 0x38, 0x39, 0x2103, 
};

/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
    {
        .range_start = 0, .range_length = 8451, .glyph_id_start = 1,
        .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 14, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
    }
};

/*--------------------
 *  ALL CUSTOM DATA
 *--------------------*/
/*Store all the custom data of the font*/
static lv_font_fmt_txt_dsc_t font_dsc = {
    .glyph_bitmap = gylph_bitmap,
    .glyph_dsc = glyph_dsc,
    .cmaps = cmaps,
    .kern_dsc = NULL,
    .kern_scale = 0,
    .cmap_num = 1,
    .bpp = 4,
    .kern_classes = 0,
    .bitmap_format = 0
};

/*-----------------
 *  PUBLIC FONT
 *----------------*/

/*Initialize a public general font descriptor*/
lv_font_t humiture_font = {
    .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt,    /*Function pointer to get glyph's data*/
    .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt,    /*Function pointer to get glyph's bitmap*/
    .line_height = 28,          /*The maximum line height required by the font*/
    .base_line = 6,             /*Baseline measured from the bottom of the line*/
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
    .subpx = LV_FONT_SUBPX_NONE,
#endif
    .dsc = &font_dsc           /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
};
#endif /*#if WEATHER_FONT*/
